const { game: gameConfig } = require('./../config');

const STORM_CARD = {
    option: {
        // icon: '',
        target: gameConfig.targets.targetHome,
        tick: 3,
    },
    handler: {
        use(card, board, ownGroup, ownRole, ownHome, targetGroups, targetRoles, targetHomes) {
            let count = ownHome.kill(card.option.value, true);
            if (count) {
                targetHomes[0].kill(count * 4);
                ownHome.addReinforce(ownRole, count);
            }
        },
        desc(card) {
            return [
                '(立即)',
                '<牺牲>',
                '[己方堡垒]',
                '中',
                `{${card.option.value}点}`,
                '<正常>',
                '[兵力]',
                '，若成功则',
                '<消灭>',
                '[敌方堡垒]',
                '牺牲数',
                `{4倍}`,
                '的',
                '[兵力]',
                '，然后为',
                '[己方堡垒]',
                '增加牺牲数',
                `{1倍}`,
                '的',
                '<增援>'
            ];
        }
    }
};

const OUTREINFORCE_CARD = {
    option: {
        // icon: '',
        target: gameConfig.targets.targetHome,
        tick: 3,
    },
    handler: {
        use(card, board, ownGroup, ownRole, ownHome, targetGroups, targetRoles, targetHomes) {
            let count = ownHome.kill(card.option.value, true);
            if (count) {
                targetHomes[0].removeReinforce(count);
            }
        },
        desc(card) {
            return [
                '(立即)',
                '<牺牲>',
                '[己方堡垒]',
                '中',
                `{${card.option.value}点}`,
                '<正常>',
                '[兵力]',
                '，若成功则随机',
                '<截杀>',
                '[敌方堡垒]',
                '{等量}',
                '批次的',
                '<增援>'
            ];
        }
    }
};

module.exports = {
    type: 'sacrifice',
    name: '死士',
    desc: '死士无惧死亡，通常使用最直接的方式与敌军对战，正所谓伤敌一千，自损八百',
    minSize: 1,
    cards: [
        STORM_CARD,
        STORM_CARD,
        STORM_CARD,
        OUTREINFORCE_CARD,
        OUTREINFORCE_CARD,
        OUTREINFORCE_CARD,
    ]
};